<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta
            name="viewport"
            content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover"
        />
        <title>bgmusic soundjs preloadjs</title>
    </head>
    <body>
        <h1>
            使用 `preloadjs`，`soundjs` 加载并播放
        </h1>
        <script src="js/common.js"></script>
        <script src="js/preloadjs.min.js"></script>
        <script src="js/soundjs.min.js"></script>
        <script>
            var soundLoadComplete = false; // 背景音乐是否加载完毕
            var backgroundMusicInstance = null; // 背景音乐实例

            var queue = new createjs.LoadQueue(true);
            queue.installPlugin(createjs.Sound);
            queue.on('complete', handleComplete, this);
            queue.loadFile({
                id: 'sound',
                src: 'bgmusic.mp3',
            });

            function handleComplete() {
                makeLog('load complete');
                soundLoadComplete = true;
                makeLog('play');
                backgroundMusicInstance = createjs.Sound.play('sound');
            }
        </script>
    </body>
</html>
